package cms.bojx.com.test;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;

public class Client {
	
	
	public static void main(String[] args) throws Exception {
//		Class<?> proxyClazz=Proxy.getProxyClass(Client.class.getClassLoader(), IHello.class);
//		Constructor<?> constructor = proxyClazz.getConstructor(InvocationHandler.class);
//		IHello iHello = (IHello) constructor.newInstance(new MyInvocation(new Hello()));
//		iHello.hello();
		
		IHello  ihello = (IHello) Proxy.newProxyInstance(Client.class.getClassLoader(),  //加载接口的类加载器
                new Class[]{IHello.class},      //一组接口
                new MyInvocation(new Hello())); //自定义的InvocationHandler
        ihello.hello();
	}
}
